from django.shortcuts import render
from rest_framework.generics import ListAPIView
# Create your views here.
from home.models import NavModel,BannerModel
from fuguang.utils import constants
from home.serializ import NavSerializer,BanerSerializer
from fuguang.utils.views import CacheListApiView

# 顶部导航
# class NavHeadView(ListAPIView):
#     queryset = NavModel.objects.filter(is_deleted=False, is_show=True, position=constants.NAV_HEARD).order_by('-id')[
#                :constants.NAV_HEARD_SIZE]
#     serializer_class = NavSerializer
#
#
# class NavFootView(ListAPIView):
#     queryset = NavModel.objects.filter(is_deleted=False, is_show=True, position=constants.NAV_FOOTER).order_by('-id')[
#                :constants.NAV_FOOTER_SIZE]
#     serializer_class = NavSerializer
#
#
# class BannerListApiView(ListAPIView):
#     queryset = BannerModel.objects.filter(is_show=True,is_deleted=False).order_by('-id')[:constants.BANNER_SIZE]
#     serializer_class = BanerSerializer


class NavHeadView(CacheListApiView):
    queryset = NavModel.objects.filter(is_deleted=False, is_show=True, position=constants.NAV_HEARD).order_by('-id')[
               :constants.NAV_HEARD_SIZE]
    serializer_class = NavSerializer


class NavFootView(CacheListApiView):
    queryset = NavModel.objects.filter(is_deleted=False, is_show=True, position=constants.NAV_FOOTER).order_by('-id')[
               :constants.NAV_FOOTER_SIZE]
    serializer_class = NavSerializer


class BannerListApiView(CacheListApiView):
    queryset = BannerModel.objects.filter(is_show=True,is_deleted=False).order_by('-id')[:constants.BANNER_SIZE]
    serializer_class = BanerSerializer
